﻿@extends('Admin.layout.blank')

@section('body')
<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 产品管理 <span class="c-gray en">&gt;</span> 品牌管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
		
	<div class="Hui-article">
		<article class="cl pd-20">
			
			<div class="cl pd-5 bg-1 bk-gray mt-20"> 
				<a class="btn btn-primary radius" onclick="brand_add('添加品牌','{{ route('ibrandadd') }}' ,',','1000','600')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加品牌</a></span>
			</div>
			
			

			<div class="mt-10">
				<table class="table table-border table-bordered table-bg table-sort">
					<thead>
						<tr class="text-c">
							<th width="70">ID</th>
							<th width="80">排序</th>
							<th width="200">LOGO</th>
							<th width="120">品牌名称</th>
							<th>具体描述</th>
							<th>URL</th>
							<th width="100">操作</th>
						</tr>
					</thead>
					<tbody>
					@if(!empty($res))
					@foreach($res as $k => $v)
						<tr class="text-c">
							<td>{{ $v->id }}</td>
							<td class="text-c">{{ $k+1 }}</td>
							<td><img width="80" src="http://oydt3ttm3.bkt.clouddn.com/{{ $v->brand_logo }}"></td>
							<td>{{ $v->brand_name }}</td>
							<td class="text-l">{{ $v->brand_desc }}</td>
							<td>
								{{ $v->site_url }}
							</td class="text-l">
							<td class="f-14 product-brand-manage">
								<a style="text-decoration:none" onClick="brand_edit('品牌编辑', '{{ route('editbrand', ['id' => $v->id]) }}' ,',','1000','600')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>
								<a style="text-decoration:none" class="ml-5" onClick="brand_del(this,{{ $v->id }})" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
							</td>
						</tr>
					@endforeach
					@else
						<tr class="text-c">
							<td colspan="7"></td>
						</tr>
					@endif
					</tbody>
				</table>
			</div>
		</article>
	</div>
</section>
@endsection

@section('footer-js')

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript" src="{{ asset('AdminPublic/lib/My97DatePicker/4.8/WdatePicker.js') }}"></script>  
<script type="text/javascript" src="{{ asset('AdminPublic/lib/datatables/1.10.0/jquery.dataTables.min.js') }}"></script> 
<script type="text/javascript" src="{{ asset('AdminPublic/lib/laypage/1.2/laypage.js') }}"></script>
<script type="text/javascript">
$('.table-sort').dataTable({
	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	"bStateSave": true,//状态保存
	"aoColumnDefs": [
	  // {"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[0,6]}// 制定列不参与排序
	]
});

/*添加*/
function brand_add(title,url,id,w,h){
	layer_show(title,url,w,h);
}


/*编辑*/
function brand_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}

/*删除*/
function brand_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type:'get',
			url:'{{route("delbrand")}}',
			data: 'id='+id,
			
			success:function (msg) {

				//品牌下有商品
				if (msg.status == 404) {
					layer.msg(msg.msg, {icon:1,time:1000});
					return false;
				}

				//删除成功
				if (msg.status == 200) {
					layer.msg(msg.msg, {icon:1,time:1000});
					$(obj).parents("tr").remove();
					return false;
				}
			},
			// error:function (e,a,b) {
			// 	errorObj = JSON.parse(e.responseText);
			// 	console.log(errorObj);
			// },
			dataType:'json'
		});
		// $(obj).parents("tr").remove();
		// layer.msg('已删除!',{icon:1,time:1000});
	});
}
</script>
<!--/请在上方写此页面业务相关的脚本-->
@endsection